<?php
/**
 * Kill cartSpiral execution and display HTML message with error message.
 *
 * Call this function complements the die() PHP function. The difference is that
 * HTML will be displayed to the user. It is recommended to use this function
 * only, when the execution should not continue any further. It is not
 * recommended to call this function very often and try to handle as many errors
 * as possible siliently.
 *
 * @since 2.0.4
 *
 * @param string $message Error message.
 * @param string $title Error title.
 * @param string|array $args Optional arguements to control behaviour.
 */
function cS_die( $message, $title = '') {

	$message = "<p>$message</p>";

header( 'Content-Type: text/html; charset=utf-8' );
	

	if ( empty($title) ) {
		if ( function_exists( '__' ) )
			$title = __( 'cartSpiral &rsaquo; Error' );
		else
			$title = 'cartSpiral &rsaquo; Error';
	}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) ) language_attributes(); ?>>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title><?php echo $title ?></title>
	<link rel="stylesheet" href="install/style.css" type="text/css" />
</head>
<body id="error-page">
	<?php echo $message; ?>
	<?php if ( strlen($message) < 512) echo str_repeat(' ', 512-strlen($message)); ?>
</body>
</html>
<?php
	die();
}

/**
 * Load the correct database class file.
 *
 * This function is used to load the database class file at runtime
 * We must globalise $cSdb to ensure that it is
 * defined globally by the inline code in cS-db-function.php.
 *
 * @since 2.5.0
 * @global $cSdb WordPress Database Object
 */
function require_cS_db() {
	global $cSdb;
	if ( file_exists( '../install/db.php' ) )
		require_once( '../install/db.php' );
	else
		require_once( '../install/cS-class-db.php' );
}


?>